﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using Puzzler.Plugin.Interface;
using Puzzler.Plugin.Interface.Attributes;

namespace Plugin.Default.SwedenGrid
{
    [PuzzleRibbonHandler]
    public sealed class SwedenGridRibbonHandler : GridPuzzleRibbonHandler<SwedenGridModel,SwedenGridCellInfo>
    {
        public SwedenGridRibbonHandler(SwedenGridModel model) : base(model)
        {
        }

        public override void OnRibbonChecked(string key)
        {
            switch (key)
            {
                case "selection_left":
                    Model.SelectionGoDirection = SelectionGoDirection.Left;
                    break;
                case "selection_right":
                    Model.SelectionGoDirection = SelectionGoDirection.Right;
                    break;
                case "selection_top":
                    Model.SelectionGoDirection = SelectionGoDirection.Top;
                    break;
                case "selection_bottom":
                    Model.SelectionGoDirection = SelectionGoDirection.Bottom;
                    break;
                case "selection_none":
                    Model.SelectionGoDirection = SelectionGoDirection.None;
                    break;
                default:
                    Console.WriteLine("WARN: Unknown ribbon key: " + key);
                    break;
            }
        }

        public override void OnRibbonSelected(string key)
        {
            switch (key.ToLower())
            {
                case "color_yellow":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.Black;
                    Model.ColorModel.QuestionBackground = Brushes.Yellow;
                    break;
                case "color_red":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.Black;
                    Model.ColorModel.QuestionBackground = Brushes.Red;
                    break;
                case "color_green":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.Black;
                    Model.ColorModel.QuestionBackground = Brushes.Green;
                    break;
                case "color_blue":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.White;
                    Model.ColorModel.QuestionBackground = Brushes.Blue;
                    break;
                case "color_cyan":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.Black;
                    Model.ColorModel.QuestionBackground = Brushes.Cyan;
                    break;
                case "color_sky":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.Black;
                    Model.ColorModel.QuestionBackground = Brushes.SkyBlue;
                    break;
                case "color_orange":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.Black;
                    Model.ColorModel.QuestionBackground = Brushes.Orange;
                    break;
                case "color_brown":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.White;
                    Model.ColorModel.QuestionBackground = Brushes.Brown;
                    break;
                case "color_pink":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.Black;
                    Model.ColorModel.QuestionBackground = Brushes.Pink;
                    break;
                case "color_violet":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.Black;
                    Model.ColorModel.QuestionBackground = Brushes.Violet;
                    break;
                case "color_black":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.White;
                    Model.ColorModel.QuestionBackground = Brushes.Black;
                    break;
                case "color_gray":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.White;
                    Model.ColorModel.QuestionBackground = Brushes.Gray;
                    break;
                case "color_white":
                    Model.ColorModel.RegularText = Brushes.Black;
                    Model.ColorModel.RegularBackground = Brushes.White;
                    Model.ColorModel.RegularBorder = Brushes.Black;
                    Model.ColorModel.QuestionBorder = Brushes.Black;
                    Model.ColorModel.QuestionText = Brushes.Black;
                    Model.ColorModel.QuestionBackground = Brushes.White;
                    break;
                default:
                    if (key.StartsWith("color_"))
                        throw new NotImplementedException(key);
                    break;
            }
        }
    }
}
